package com.googlecode.intellimars.vfs;

import com.intellij.openapi.components.ProjectComponent;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileManager;
import org.jetbrains.annotations.NotNull;

public class VfsSamplePlugin implements ProjectComponent {
    private Project project;
    private MyVfsListener myVfsListener;

    public VfsSamplePlugin(Project _project) {
        project = _project;
    }

    public void initComponent() {
        // TODO: insert component initialization logic here
    }

    public void disposeComponent() {
        // TODO: insert component disposal logic here
    }

    @NotNull
    public String getComponentName() {
        return "VfsSamplePlugin";
    }

    public void projectOpened() {
        myVfsListener = new MyVfsListener(project);
        VirtualFileManager.getInstance().addVirtualFileListener(myVfsListener);
    }

    public void projectClosed() {
        VirtualFileManager.getInstance().removeVirtualFileListener(myVfsListener);
    }
}
